﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Modules.Core;

namespace ComputerStoreManager.ViewModel {
    public delegate void OnHomeCommandEventHander();
    public delegate void OnEmployeeCommandEventHander();
    public delegate void OnCustomerCommandEventHander();
    public delegate void OnProductCommandEventHander();
    public delegate void OnInvoiceCommandEventHander();
    public delegate void OnStatisticsCommandEventHander();
    public delegate void OnExitCommandEventHander();

    public class MenuControlViewModel {

        #region Events
        public event OnHomeCommandEventHander OnHomeCommandClicked;
        public event OnHomeCommandEventHander OnEmployeeCommandClicked;
        public event OnHomeCommandEventHander OnCustomerCommandClicked;
        public event OnHomeCommandEventHander OnProductCommandClicked;
        public event OnHomeCommandEventHander OnInvoiceCommandClicked;
        public event OnHomeCommandEventHander OnStatisticsCommandClicked;
        public event OnExitCommandEventHander OnExitCommandClicked;
        #endregion

        #region Command
        public ICommand ExitCommand {
            get;
            private set;
        }
        public ICommand HomeCommand {
            get;
            private set;
        }
        public ICommand EmployeeCommand {
            get;
            private set;
        }
        public ICommand CustomerCommand {
            get;
            private set;
        }
        public ICommand ProductCommand {
            get;
            private set;
        }
        public ICommand InvoiceCommand {
            get;
            private set;
        }
        public ICommand StatisticsCommand {
            get;
            private set;
        }
        #endregion

        #region Init command

        private void InitCmd() {
            HomeCommand = new ExecutableCommand(DoHomeCommand);
            EmployeeCommand = new ExecutableCommand(DoEmployeeCommand);
            CustomerCommand = new ExecutableCommand(DoCustomerCommand);
            ProductCommand = new ExecutableCommand(DoProductCommand);
            InvoiceCommand = new ExecutableCommand(DoInvoiceCommand);
            StatisticsCommand = new ExecutableCommand(DoStatisticsCommand);
            ExitCommand = new ExecutableCommand(DoExit);

        }

        private void DoExit(object obj) {
            if (OnExitCommandClicked != null) {
                OnExitCommandClicked();
            }
        }

        private void DoStatisticsCommand() {
            if (OnStatisticsCommandClicked != null) {
                OnStatisticsCommandClicked();
            }
        }

        private void DoInvoiceCommand() {
            if (OnInvoiceCommandClicked != null) {
                OnInvoiceCommandClicked();
            }
        }

        private void DoProductCommand() {
            if (OnProductCommandClicked != null) {
                OnProductCommandClicked();
            }
        }

        private void DoCustomerCommand() {
            if (OnCustomerCommandClicked != null) {
                OnCustomerCommandClicked();
            }
        }

        private void DoEmployeeCommand() {
            if (OnEmployeeCommandClicked != null) {
                OnEmployeeCommandClicked();
            }
        }

        private void DoHomeCommand() {
            if(OnHomeCommandClicked != null) {
                OnHomeCommandClicked();
            }
        }

        #endregion

        public MenuControlViewModel() {
            InitCmd();
        }
    }
}
